<%--
  Created by IntelliJ IDEA.
  User: HUI
  Date: 2020/12/21
  Time: 11:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>登录</title>
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>

    <link href="https://v3.bootcss.com/examples/signin/signin.css" rel="stylesheet">

</head>
<body>
<div class="container">

    <form class="form-signin">
        <h2 class="form-signin-heading" >登录</h2>
        <label for="inputEmail" class="sr-only">Email address</label>
        <input type="email" id="inputEmail" class="form-control" placeholder="请输入账号" required autofocus>
        <br/>
        <label for="inputPassword" class="sr-only">Password</label>
        <input type="password" id="inputPassword" class="form-control" placeholder="请输入密码" required>
        <div class="check-box">
            <label>
<%--                <input type="checkbox" value="remember-me"> Remember me--%>
                <p id="msg" style="color: red"></p>
            </label>
        </div>
<%--        <button class="btn btn-lg btn-primary btn-block" onclick="login()">Sign in</button>--%>
        <input class="btn btn-lg btn-primary btn-block" type="button" value="登录" onclick="login()">
    </form>



</div> <!-- /container -->

<script>

    function login(){
        const username = $('#inputEmail').val();
        const password = $('#inputPassword').val();
        $.post("/login",{"username":username,"password":password},function(data){

            if(data["code"]=="200"){
                window.location.href = "/admin";
            }else{
                $("#msg").html(data["msg"]);
                console.log(data)
            }
        });

    }


</script>

</body>
</html>
